-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMPORT] Intégrer les champs d'import lors de l'installation d'un protocole #398
base: develop
Are you sure you want to change the base?
[IMPORT] Intégrer les champs d'import lors de l'installation d'un protocole #398
Conversation
…nX-SI#391) * Fix edit map mode * Reinit leafletdraw config
* VESION and requirements.in * Docs * Changelog 1.0.0 / complément * Update README.md * Update docs/changelog.md * Bump GeoNature * Add postgis ltree extension * Suppression données orpheline synthese * Use geonature 03b_populate_db.sh script * Changelog --------- Co-authored-by: Camille Monchicourt <[email protected]>
…tions/gn_module_monitoring into feat/import/install-protocol
Il faudrait rebaser la branche de destination sur DEVELOP, car là la PR semble ajouter des commits qui sont liés à d'autres évolutions récentes de DEVELOP. |
* VESION and requirements.in * Docs * Changelog 1.0.0 / complément * Update README.md * Update docs/changelog.md * Bump GeoNature * Add postgis ltree extension * Suppression données orpheline synthese * Use geonature 03b_populate_db.sh script * Changelog --------- Co-authored-by: Camille Monchicourt <[email protected]>
…tions/gn_module_monitoring into feat/import/install-protocol
from geonature.core.imports.models import BibFields | ||
from geonature.core.imports.models import Destination | ||
from geonature.core.imports.models import Entity | ||
from geonature.core.imports.models import EntityField | ||
from geonature.core.imports.models import BibThemes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from geonature.core.imports.models import BibFields | |
from geonature.core.imports.models import Destination | |
from geonature.core.imports.models import Entity | |
from geonature.core.imports.models import EntityField | |
from geonature.core.imports.models import BibThemes | |
from geonature.core.imports.models import BibFields, Destination, Entity, EntityField, BibThemes |
Destination: L'objet Destination inséré ou mis à jour. | ||
""" | ||
existing_destination = ( | ||
DB.session.query(Destination).filter_by(code=module_data["module_code"]).one_or_none() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DB.session.query(Destination).filter_by(code=module_data["module_code"]).one_or_none() | |
DB.session.execute(select(Destination).filter_by(code=module_data["module_code"])).scalar_one_or_none() |
destination = Destination() | ||
destination.from_dict(destination_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
destination = Destination() | |
destination.from_dict(destination_data) | |
destination = Destination(**destination_data) |
DB.session.commit() | ||
return existing_destination | ||
|
||
module_monitoring_code = DB.session.query(TModules).filter_by(module_code=module_data["module_code"]).one() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module_monitoring_code = DB.session.query(TModules).filter_by(module_code=module_data["module_code"]).one() | |
module_monitoring_code = DB.session.execute(select(TModules).filter_by(module_code=module_data["module_code"])).scalar_one() |
|
||
fields.append(create_bib_field(field_data, entity_code, field_name, id_destination, json.dumps(field_data))) | ||
|
||
if field_data.get("required", False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Les champs additionnels peuvent être requis ?
…refactor function, add distinction between generic and specific field
Args: | ||
module_data (dict): Données de la table gn_commons.t_modules du module à importer. | ||
""" | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ajouter db.session.begin_nested(). Cela permettra d'annuler toutes les transactions effectuées si une des requêtes échoue. https://docs.sqlalchemy.org/en/20/orm/session_transaction.html#using-savepoint
Destination: L'objet Destination inséré ou mis à jour. | ||
""" | ||
existing_destination = ( | ||
DB.session.execute(select(Destination).filter_by(code=module_data["module_code"])).scalar_one_or_none() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DB.session.execute(select(Destination).filter_by(code=module_data["module_code"])).scalar_one_or_none() | |
DB.session.execute(sa.exists(Destination).where(Destination.code ==module_data["module_code"]).select()) |
Args: | ||
field_data (dict): Données du champ | ||
|
||
Returns: | ||
str: Type de colonne PostgreSQL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
De préférence au format numpy, https://numpydoc.readthedocs.io/en/latest/format.html
if DB.session.execute( | ||
select(EntityField) | ||
.filter_by(id_entity=entity_id, id_field=id_field) | ||
).one_or_none(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A remplacer par une requête exists
[IMPORT][MONITORING] IM_IMPORT_01.0 - Intégrer les champs d'import lors de l'installation d'un protocole https://github.com/orgs/PnX-SI/projects/13/views/6?pane=issue&itemId=83656221
Intégration des champs d'import lors de l'installation d'un protocole
Ajout dans la table
bib_destinations
bib_destinations
.Récupération et insertion des entités
config.json
du module.bib_entities
.Gestion des champs spécifiques et génériques
bib_fields
etcor_entity_field
.Création de la table d'import
t_import_{protocole}
.gn_imports
.